<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Load Binary Kits Stage</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-1.12.4.min.js"
	integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>

<script src="../docs-assets/Bigfoot.js"></script>
<link href="../docs-assets/Bigfoot.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Load Binary Kits Stage' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../intern.html">Inter Modules</a></li><li><a href="index.html">pipeline</a></li><li><a href="index.html#4">Chapter 4: Linking</a></li><li><b>Load Binary Kits Stage</b></li></ul></div>
<p class="purpose">Reading other Inter trees as binary files, and attaching them at given points in the main Inter tree.</p>

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>Inform 7 compiles source text to a single "main" Inter tree. That tree must
then be joined with other Inter trees for kits such as BasicInformKit, a
process called "linking", for want of a better word.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>
</p>

<p class="commentary">Only the <a href="../supervisor-module/index.html" class="internal">supervisor</a> module knows which kits need to be linked in; the main
Inter tree doesn't contain this information.<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>
</p>

<ul class="footnotetexts"><li class="footnote" id="fn:1"><p class="inwebfootnote"><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> Unlike the C linking process, it is not symmetrical. One Inter tree is
made by <a href="../inter/index.html" class="internal">inter</a>, and the others by <a href="../inter/index.html" class="internal">inter</a>, for one thing.
<a href="#fnref:1" title="return to text"> &#x21A9;</a></p></li><li class="footnote" id="fn:2"><p class="inwebfootnote"><sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup> Just as a C-compiled binary may be made by linking <span class="extract"><span class="extract-syntax">alpha.o</span></span>, <span class="extract"><span class="extract-syntax">beta.o</span></span> and
<span class="extract"><span class="extract-syntax">gamma.o</span></span> together, but the fact that these are the three <span class="extract"><span class="extract-syntax">*.o</span></span> files needed
to make the finished article is recorded only in the makefile for the program.
It's a matter for the build process and not for the compiler.
<a href="#fnref:2" title="return to text"> &#x21A9;</a></p></li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>The list of Inter trees to link with is worked out by the <a href="../supervisor-module/index.html" class="internal">supervisor</a>,
which calls the following function to obtain a way to record each "requirement":
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">attachment_instruction</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">attachment_point</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">attachment_instruction</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">attachment_instruction</span><span class="plain-syntax"> *</span><span class="function-syntax">LoadBinaryKitsStage::new_requirement</span><span class="plain-syntax">(</span><span class="identifier-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">attach</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">attachment_instruction</span><span class="plain-syntax"> *</span><span class="identifier-syntax">link</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">attachment_instruction</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">link</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">link</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">attachment_point</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">attach</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">link</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure attachment_instruction is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>Linking begins with the following stage. Note that the list of requirements
made by <a href="../supervisor-module/index.html" class="internal">supervisor</a> is now stored in <span class="extract"><span class="extract-syntax">step-&gt;ephemera.requirements_list</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">LoadBinaryKitsStage::create_pipeline_stage</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">LoadBinaryKitsStage::create_pipeline_stage</span></span>:<br/>Parsing Pipelines - <a href="2-pp.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="2-pp.html#SP3" class="function-link"><span class="function-syntax">ParsingPipelines::new_stage</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"load-binary-kits"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><a href="4-lbks.html#SP3" class="function-link"><span class="function-syntax">LoadBinaryKitsStage::run</span></a><span class="plain-syntax">, </span><span class="constant-syntax">NO_STAGE_ARG</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">LoadBinaryKitsStage::run</span><span class="plain-syntax">(</span><span class="reserved-syntax">pipeline_step</span><span class="plain-syntax"> *</span><span class="identifier-syntax">step</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax"> = </span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ephemera</span><span class="plain-syntax">.</span><span class="element-syntax">tree</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">attachment_instruction</span><span class="plain-syntax"> *</span><span class="identifier-syntax">req</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">req</span><span class="plain-syntax">, </span><span class="reserved-syntax">attachment_instruction</span><span class="plain-syntax">, </span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ephemera</span><span class="plain-syntax">.</span><span class="element-syntax">requirements_list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sidecar</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterTree::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-lbks.html#SP3_1" class="named-paragraph-link"><span class="named-paragraph">Load the Inter for the kit into the sidecar</span><span class="named-paragraph-number">3.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-lbks.html#SP3_2" class="named-paragraph-link"><span class="named-paragraph">Look for duplicate definitions</span><span class="named-paragraph-number">3.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-lbks.html#SP3_3" class="named-paragraph-link"><span class="named-paragraph">Migrate the bulk of the code from the sidecar to the main tree</span><span class="named-paragraph-number">3.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Wiring::connect_plugs_to_sockets</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3_1" class="paragraph-anchor"></a><b>&#167;3.1. </b>A kit will, if properly prepared, contain a binary Inter file for each possible
architecture which may be needed. For testing purposes, the following actually
allows a textual Inter file to be used instead, but this isn't intended for
regular users: it would be quite slow to read in.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Load the Inter for the kit into the sidecar</span><span class="named-paragraph-number">3.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_architecture</span><span class="plain-syntax"> *</span><span class="identifier-syntax">A</span><span class="plain-syntax"> = </span><a href="1-pm.html#SP4" class="function-link"><span class="function-syntax">PipelineModule::get_architecture</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">Errors::fatal</span><span class="plain-syntax">(</span><span class="string-syntax">"no -architecture given"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">arch_file</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Architectures::canonical_binary</span><span class="plain-syntax">(</span><span class="identifier-syntax">req</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">location</span><span class="plain-syntax">, </span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TextFiles::exists</span><span class="plain-syntax">(</span><span class="identifier-syntax">arch_file</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">BinaryInter::test_file</span><span class="plain-syntax">(</span><span class="identifier-syntax">arch_file</span><span class="plain-syntax">)) </span><span class="identifier-syntax">BinaryInter::read</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar</span><span class="plain-syntax">, </span><span class="identifier-syntax">arch_file</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">TextualInter::read</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar</span><span class="plain-syntax">, </span><span class="identifier-syntax">arch_file</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-lbks.html#SP3">&#167;3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_2" class="paragraph-anchor"></a><b>&#167;3.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Look for duplicate definitions</span><span class="named-paragraph-number">3.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sidecar_connectors</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LargeScale::connectors_package_if_it_exists</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sidecar_connectors</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterPackage::scope</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar_connectors</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER_SYMBOLS_TABLE</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">InterSymbol::is_socket</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">defn_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterSymbol::identifier</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rival</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wiring::find_socket</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rival</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sidecar_end</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rival_end</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">rival</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">InterSymbol::get_flag</span><span class="plain-syntax">(</span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">PERMIT_NAME_CLASH_ISYMF</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">                        (</span><span class="identifier-syntax">SymbolAnnotation::get_b</span><span class="plain-syntax">(</span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">PRIVATE_IANN</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">                        (</span><span class="identifier-syntax">SymbolAnnotation::get_b</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">PRIVATE_IANN</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                        </span><span class="named-paragraph-container code-font"><a href="4-lbks.html#SP3_2_1" class="named-paragraph-link"><span class="named-paragraph">A clash of definitions seems to have occurred</span><span class="named-paragraph-number">3.2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-lbks.html#SP3">&#167;3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_2_1" class="paragraph-anchor"></a><b>&#167;3.2.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">A clash of definitions seems to have occurred</span><span class="named-paragraph-number">3.2.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"Rival definitions of '%S':\ntree: $3\nkit: $3\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">override</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NOT_APPLICABLE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">L</span><span class="plain-syntax"> = </span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">pipeline</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ephemera</span><span class="plain-syntax">.</span><span class="element-syntax">replacements_list</span><span class="plain-syntax">[</span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">tree_argument</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">N</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">)) </span><span class="identifier-syntax">override</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">tree_replaces</span><span class="plain-syntax"> = </span><a href="4-lbks.html#SP5" class="function-link"><span class="function-syntax">LoadBinaryKitsStage::replaces</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">kit_replaces</span><span class="plain-syntax"> = </span><a href="4-lbks.html#SP5" class="function-link"><span class="function-syntax">LoadBinaryKitsStage::replaces</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">), </span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tree_replaces</span><span class="plain-syntax">) </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"$3 replaces $3\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">kit_replaces</span><span class="plain-syntax">) </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"$3 replaces $3\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">), </span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">tree_replaces</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">kit_replaces</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)) </span><span class="identifier-syntax">override</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">tree_replaces</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">kit_replaces</span><span class="plain-syntax"> == </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">)) </span><span class="identifier-syntax">override</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">override</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NOT_APPLICABLE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">r_val</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ConstantInstruction::evaluate_to_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">s_val</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ConstantInstruction::evaluate_to_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar_end</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">r_val</span><span class="plain-syntax"> == </span><span class="identifier-syntax">s_val</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">r_val</span><span class="plain-syntax"> != -1)) </span><span class="identifier-syntax">override</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">override</span><span class="plain-syntax"> == </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="4-lbks.html#SP3_2_1_1" class="named-paragraph-link"><span class="named-paragraph">Override the new definition with the existing one</span><span class="named-paragraph-number">3.2.1.1</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">override</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="4-lbks.html#SP3_2_1_2" class="named-paragraph-link"><span class="named-paragraph">Override the existing definition with the new one</span><span class="named-paragraph-number">3.2.1.2</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">InterSymbol::get_flag</span><span class="plain-syntax">(</span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">MAKE_NAME_UNIQUE_ISYMF</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-lbks.html#SP3_2_1_3" class="named-paragraph-link"><span class="named-paragraph">Throw an error for the duplication</span><span class="named-paragraph-number">3.2.1.3</span></a></span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-lbks.html#SP3_2">&#167;3.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_2_1_1" class="paragraph-anchor"></a><b>&#167;3.2.1.1. </b>The following (unfortunately) has to do something subtle. We need the definition
of <span class="extract"><span class="extract-syntax">defn_name</span></span> to be the one in the main tree; that means <span class="extract"><span class="extract-syntax">sidecar_end</span></span> has to have
its present definition struck, i.e., removed entirely from the <span class="extract"><span class="extract-syntax">sidecar</span></span> tree.
This may remove something as simple as a single constant definition, or as large
as a huge package holding the body of a function. Then, <span class="extract"><span class="extract-syntax">sidecar_end</span></span> has to
be redefined as something in the main tree. But since transmigration has not yet
happened, we can't just wire it there. We have to wire it to a plug with name
<span class="extract"><span class="extract-syntax">defn_tree</span></span> instead; and then after transmigration this will be connected to a
socket in the main tree connecting to <span class="extract"><span class="extract-syntax">rival_end</span></span>.
</p>

<p class="commentary">But even that isn't quite enough. We can't allow the <span class="extract"><span class="extract-syntax">connectors</span></span> package of
<span class="extract"><span class="extract-syntax">sidecar</span></span> to contain a socket name which is the same as a socket name in the
<span class="extract"><span class="extract-syntax">connectors</span></span> package of the main tree <span class="extract"><span class="extract-syntax">I</span></span>. It might seem that we can just delete
the now-unwanted socket wired to the old definition; but we cannot, because other
symbols in the same kit might already be wired to it. So we keep the old socket,
but rename it with a name which will avoid name collisions, striking it out of
the symbols table dictionary.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Override the new definition with the existing one</span><span class="named-paragraph-number">3.2.1.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">InterSymbolsTable::unname</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"cannot strike socket name"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">plug</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wiring::plug</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar</span><span class="plain-syntax">, </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-lbks.html#SP4" class="function-link"><span class="function-syntax">LoadBinaryKitsStage::deal_with_original</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">step</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SymbolAnnotation::get_b</span><span class="plain-syntax">(</span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">KEEPING_IANN</span><span class="plain-syntax">), </span><span class="identifier-syntax">sidecar_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">sidecar</span><span class="plain-syntax">, </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">InterSymbol::undefine</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar_end</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Wiring::wire_to</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">plug</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"After overriding the kit definition, we have:\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"Socket renamed as $3 ~~&gt; $3\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"A new plug $3\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">plug</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"Kit defn symbol $3 ~~&gt; $3\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">sidecar_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar_end</span><span class="plain-syntax">));</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-lbks.html#SP3_2_1">&#167;3.2.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_2_1_2" class="paragraph-anchor"></a><b>&#167;3.2.1.2. </b>And vice versa.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Override the existing definition with the new one</span><span class="named-paragraph-number">3.2.1.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">main_connectors</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LargeScale::connectors_package_if_it_exists</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">main_connectors</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterPackage::scope</span><span class="plain-syntax">(</span><span class="identifier-syntax">main_connectors</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">InterSymbolsTable::unname</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"cannot strike socket name"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">plug</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wiring::plug</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-lbks.html#SP4" class="function-link"><span class="function-syntax">LoadBinaryKitsStage::deal_with_original</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">step</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SymbolAnnotation::get_b</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">KEEPING_IANN</span><span class="plain-syntax">), </span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Wiring::wire_to</span><span class="plain-syntax">(</span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">plug</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Wiring::wire_to</span><span class="plain-syntax">(</span><span class="identifier-syntax">plug</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"After overriding the tree definition, we have:\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"A new plug $3\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">plug</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"Tree defn symbol $3 ~~&gt; $3\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">));</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-lbks.html#SP3_2_1">&#167;3.2.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_2_1_3" class="paragraph-anchor"></a><b>&#167;3.2.1.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Throw an error for the duplication</span><span class="named-paragraph-number">3.2.1.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Rival definitions of '%S':\ntree: $3\nkit: $3\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">rival_end</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wiring::cable_end</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"found a second definition of the name '%S' when loading '%S'"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">req</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">attachment_point</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-pe.html#SP2" class="function-link"><span class="function-syntax">PipelineErrors::error_with</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">step</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">)</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-lbks.html#SP3_2_1">&#167;3.2.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_3" class="paragraph-anchor"></a><b>&#167;3.3. </b>The "attachment point" for the kit will be something like <span class="extract"><span class="extract-syntax">/main/BasicInformKit</span></span>.
(This point will be different for each different kit in the requirements list:
others might include <span class="extract"><span class="extract-syntax">/main/CommandParserKit</span></span>, and so on.) We take that package out
of the sidecar and put it into the main tree.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Migrate the bulk of the code from the sidecar to the main tree</span><span class="named-paragraph-number">3.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterPackage::from_URL</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar</span><span class="plain-syntax">, </span><span class="identifier-syntax">req</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">attachment_point</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">STDERR</span><span class="plain-syntax">, </span><span class="string-syntax">"sought attachment material at: %S\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">req</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">attachment_point</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"unable to find attachment point package"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Transmigration::move</span><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">, </span><span class="identifier-syntax">LargeScale::main_package</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-lbks.html#SP3">&#167;3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">LoadBinaryKitsStage::deal_with_original</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">LoadBinaryKitsStage::deal_with_original</span></span>:<br/><a href="4-lbks.html#SP3_2_1_1">&#167;3.2.1.1</a>, <a href="4-lbks.html#SP3_2_1_2">&#167;3.2.1.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">pipeline_step</span><span class="plain-syntax"> *</span><span class="identifier-syntax">step</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">keeping</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sidecar</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">keeping</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-lbks.html#SP4_1" class="named-paragraph-link"><span class="named-paragraph">Keep the original definition</span><span class="named-paragraph-number">4.1</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-lbks.html#SP4_2" class="named-paragraph-link"><span class="named-paragraph">Destroy the original definition</span><span class="named-paragraph-number">4.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4_1" class="paragraph-anchor"></a><b>&#167;4.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Keep the original definition</span><span class="named-paragraph-number">4.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"Keeping original definition of $3\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">rname</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">rname</span><span class="plain-syntax">, </span><span class="string-syntax">"replaced`%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">replaced</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InterSymbolsTable::symbol_from_name_creating</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">owning_table</span><span class="plain-syntax">, </span><span class="identifier-syntax">rname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterSymbol::definition</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">InterSymbol::define</span><span class="plain-syntax">(</span><span class="identifier-syntax">replaced</span><span class="plain-syntax">, </span><span class="identifier-syntax">D</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Inode::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="identifier-syntax">CONSTANT_IST</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">D</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">W</span><span class="plain-syntax">.</span><span class="identifier-syntax">instruction</span><span class="plain-syntax">[</span><span class="identifier-syntax">DEFN_CONST_IFLD</span><span class="plain-syntax">] = </span><span class="identifier-syntax">replaced</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">symbol_ID</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Inode::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="identifier-syntax">PACKAGE_IST</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">D</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">W</span><span class="plain-syntax">.</span><span class="identifier-syntax">instruction</span><span class="plain-syntax">[</span><span class="identifier-syntax">DEFN_PACKAGE_IFLD</span><span class="plain-syntax">] = </span><span class="identifier-syntax">replaced</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">symbol_ID</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Inode::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="identifier-syntax">VARIABLE_IST</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">D</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">W</span><span class="plain-syntax">.</span><span class="identifier-syntax">instruction</span><span class="plain-syntax">[</span><span class="identifier-syntax">DEFN_VAR_IFLD</span><span class="plain-syntax">] = </span><span class="identifier-syntax">replaced</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">symbol_ID</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"\n***** Unable to keep this:\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InterInstruction::write_construct_text_allowing_nop</span><span class="plain-syntax">(</span><span class="identifier-syntax">DL</span><span class="plain-syntax">, </span><span class="identifier-syntax">D</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"*****\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="2-pe.html#SP2" class="function-link"><span class="function-syntax">PipelineErrors::error_with</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">step</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"'keeping' is only for routines, global variables and constants, which '%S' is not"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">defn_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Wiring::socket_one_per_name_only</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar</span><span class="plain-syntax">, </span><span class="identifier-syntax">rname</span><span class="plain-syntax">, </span><span class="identifier-syntax">replaced</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">rname</span><span class="plain-syntax">)</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-lbks.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_2" class="paragraph-anchor"></a><b>&#167;4.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Destroy the original definition</span><span class="named-paragraph-number">4.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_CONNECTORS</span><span class="plain-syntax">, </span><span class="string-syntax">"Destroying original definition of $3\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">InterSymbol::strike_definition</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-lbks.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>This function determines whether a replacement should take place: if the
symbol has been marked simple <span class="extract"><span class="extract-syntax">+replacing</span></span> then the original location is set
to the special value <span class="extract"><span class="extract-syntax">_</span></span> meaning "from anywhere", whereas otherwise it must
be a package name such as <span class="extract"><span class="extract-syntax">BasicInformKit</span></span>, arising from an annotation like
<span class="extract"><span class="extract-syntax">+replacing(from BasicInformKit)</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">LoadBinaryKitsStage::replaces</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">LoadBinaryKitsStage::replaces</span></span>:<br/><a href="4-lbks.html#SP3_2_1">&#167;3.2.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">X_rep</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterSymbol::get_replacement</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">X_rep</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"_"</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterSymbolsTable::package</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">owning_table</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">X_rep</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterPackage::name</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">))) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterPackage::parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="3-css.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-pm.html">1</a></li><li class="progresschapter"><a href="2-pp.html">2</a></li><li class="progresschapter"><a href="3-ps.html">3</a></li><li class="progresscurrentchapter">4</li><li class="progresscurrent">lbks</li><li class="progresssection"><a href="4-sws.html">sws</a></li><li class="progresssection"><a href="4-dics.html">dics</a></li><li class="progresssection"><a href="4-mius.html">mius</a></li><li class="progresssection"><a href="4-rvs.html">rvs</a></li><li class="progresssection"><a href="4-tsk.html">tsk</a></li><li class="progresschapter"><a href="5-msms.html">5</a></li><li class="progresschapter"><a href="6-erms.html">6</a></li><li class="progressnext"><a href="4-sws.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

